package config

import (
	"encoding/json"
	"io/ioutil"
	"log"
)

type Config struct {
	DatabaseType          string `json:"database_type"`
	SQLitePath            string `json:"sqlite_path"`
	MySQLConnectionString string `json:"mysql_connection_string"`
	WebPort               string `json:"web_port"`
	MainStationURL        string `json:"main_station_url"`
	PollingInterval       int    `json:"polling_interval"`
	MaxThreads            int    `json:"max_threads"`
	LogRetentionDays      int    `json:"log_retention_days"`
}

var Cfg Config

func LoadConfig(path string) {
	file, err := ioutil.ReadFile(path)
	if err != nil {
		log.Fatal(err)
	}
	err = json.Unmarshal(file, &Cfg)
	if err != nil {
		log.Fatal(err)
	}
}
